#include <bits/stdc++.h>
using namespace std;

int main() {
  freopen("censor.in", "r", stdin);
  freopen("censor.out", "w", stdout);
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s, t;

  cin >> s >> t;

  s = '#' + s;
  vector<int> next(s.size(), -1), prev(s.size(), -1);
  for (int i = 1; i < s.size(); i++) {
    next[i - 1] = i;
    prev[i] = i - 1;
  }

  int st = 0;
  while (1) {
    bool del = false;
    for (int i = st; next[i] != -1; i = next[i]) {
      int pos, j;

      for (pos = next[i], j = 0; j < t.size() && pos != -1; pos = next[pos], j++) {
        if (s[pos] != t[j]) {
          break;
        }
      }
      if (j == t.size()) {
        del = true;
        next[i] = pos;
        if (pos != -1) {
          prev[pos] = i;
        }
        st = i;
        for (int k = 0; k < t.size() && st != 0; k++, st = prev[st]);
        break;
      }
    }
    if (del == false) {
      break;
    }
  }

  for (int i = next[0]; i != -1; i = next[i]) {
    cout << s[i];
  }
  cout << "\n";
  return 0;
}